<%@page import="com.liferay.portal.kernel.util.Validator"%>
<%@page import="qldc.pm.tienan.searchcontainer.BienBanBanGiaoHoSoSearchTerms"%>
<%@page import="qldc.pm.tienan.searchcontainer.BienBanBanGiaoHoSoDisplayTerms"%>
<%@page import="qldc.pm.tienan.searchcontainer.BienBanBanGiaoHoSoSearch"%>
<%@page import="qldc.pm.tienan.service.BienBanBanGiaoHoSoLocalServiceUtil"%>
<%@page import="qldc.pm.tienan.model.BienBanBanGiaoHoSo"%>
<%@page import="com.liferay.portal.kernel.util.Constants"%>
<%@page import="java.text.SimpleDateFormat"%>

<%@include file="../../init.jsp"%>

<%
String pathThemeImages = themeDisplay.getPathThemeImages();
SimpleDateFormat sdf = new SimpleDateFormat(TienAnConstants.DATE_PATTERN);

PortletURL portletURL = renderResponse.createRenderURL();
portletURL.setParameter("mvcPath", "/html/view.jsp");
portletURL.setParameter("chonChucNangItem", TienAnConstants.LAP_BIEN_BAN_BAN_GIAO_HO_SO);
%>

<portlet:renderURL var="themMoiBienBanBanGiao">
	<portlet:param name="mvcPath" value="/html/view.jsp"/>
	<portlet:param name="chonChucNangItem" value="<%=TienAnConstants.LAP_BIEN_BAN_BAN_GIAO_HO_SO %>"/>
	<portlet:param name="tabs1" value="lap_bien_ban"/>
	<portlet:param name="redirect" value="<%=portletURL.toString() %>"/>
	<portlet:param name="mode" value="add"/>
</portlet:renderURL>

<form action="<%=portletURL.toString() %>" method="POST" id="<portlet:namespace />fm" name="<portlet:namespace />fm">
	<input type="hidden" name="<portlet:namespace />cmd" id="<portlet:namespace />cmd">

	<%
	BienBanBanGiaoHoSoSearch bienBanBanGiaoSearch = new BienBanBanGiaoHoSoSearch(renderRequest, portletURL);
	BienBanBanGiaoHoSoDisplayTerms displayTerms = (BienBanBanGiaoHoSoDisplayTerms) bienBanBanGiaoSearch.getDisplayTerms();
	BienBanBanGiaoHoSoSearchTerms searchTerms = (BienBanBanGiaoHoSoSearchTerms) bienBanBanGiaoSearch.getSearchTerms();
	%>
	
	<table class="global-Search">
		<tr>
			<td class="aui-w20"><liferay-ui:message key="ban-giao-cho-ong-ba" /></td>
			<td class="aui-w30"><input type="text" name="<portlet:namespace/><%=BienBanBanGiaoHoSoDisplayTerms.NGUOI_DUOC_BAN_GIAO %>" value="<%=searchTerms.getNguoiDuocBanGiao() %>" /></td>
			<td class="aui-w50"></td>
		</tr>

		<tr>	
			<td><liferay-ui:message key="chuc-vu" /></td>
			<td>
				<input type="text" name="<portlet:namespace/><%=BienBanBanGiaoHoSoDisplayTerms.CHUC_VU_NGUOI_DUOC_BAN_GIAO %>" value="<%=searchTerms.getChucVuNguoiDuocBanGiao() %>" />
			</td>
			<td></td>
		</tr>

		<tr>
			<td></td>
			<td colspan="3">
				<div align="left">
					<input type="submit" onclick="timKiem()" class="btn btn-primary" value="<liferay-ui:message key="tim" />" />
					<input type="button" onclick="javascript:submitForm(document.hrefFm,'<%= themMoiBienBanBanGiao.toString() %>');"  class="btn btn-danger" value="<liferay-ui:message key="tao-moi-bien-ban" />" />
				</div>
			</td>
		</tr>	
	</table>
</form>

<liferay-ui:search-container  searchContainer="<%=bienBanBanGiaoSearch %>">
	<liferay-ui:search-container-results>		
		<%
		results = BienBanBanGiaoHoSoLocalServiceUtil.findByNguoiDuocBanGiao_ChucVu(searchTerms.getNguoiDuocBanGiao(),
			searchTerms.getChucVuNguoiDuocBanGiao()									
			,bienBanBanGiaoSearch.getStart(), bienBanBanGiaoSearch.getEnd(), 
			bienBanBanGiaoSearch.getOrderByComparator());
				
		total = BienBanBanGiaoHoSoLocalServiceUtil.countByNguoiDuocBanGiao_ChucVu(searchTerms.getNguoiDuocBanGiao(),
				searchTerms.getChucVuNguoiDuocBanGiao());	
		pageContext.setAttribute("results", results);
		pageContext.setAttribute("total", total);
		%>
	</liferay-ui:search-container-results>
	<%
	int start = bienBanBanGiaoSearch.getDelta() * (bienBanBanGiaoSearch.getCur() - 1);
	%>
	<liferay-ui:search-container-row className="qldc.pm.tienan.model.BienBanBanGiaoHoSo" keyProperty="bienBanBanGiaoHoSoId" modelVar="bienBanBanGiaoHoSo" >
		<liferay-ui:search-container-column-text cssClass="aui-w3 txt-center" name='stt' value="<%=String.valueOf(++start) %>" />
		
		<liferay-ui:search-container-column-text cssClass="aui-w15" name='nguoi-lap' property="nguoiLap" orderable="<%=true %>" orderableProperty="nguoiLap" />
		<liferay-ui:search-container-column-text name='ban-giao-cho-ong-ba' property="nguoiDuocBanGiao" orderable="<%=true %>" orderableProperty="nguoiDuocBanGiao"/>
		<liferay-ui:search-container-column-text name='chuc-vu' property="chucVuNguoiDuocBanGiao"/>
		<liferay-ui:search-container-column-text name='ngay-lap' ><%=Validator.isNotNull(bienBanBanGiaoHoSo.getNgayLap())? sdf.format(bienBanBanGiaoHoSo.getNgayLap()):"" %></liferay-ui:search-container-column-text>
		<liferay-ui:search-container-column-text cssClass="txt-center" name='ngay-ban-giao'><%=Validator.isNotNull(bienBanBanGiaoHoSo.getNgayBanGiao()) ? sdf.format(bienBanBanGiaoHoSo.getNgayBanGiao()) :""%></liferay-ui:search-container-column-text>
		<liferay-ui:search-container-column-text name='ly-do-ban-giao' property="noiDung" />

		<liferay-ui:search-container-column-jsp cssClass="aui-Action" path="/html/tienan/lap_bien_ban_ban_giao_ho_so/actions.jsp" align="right" />
	</liferay-ui:search-container-row>
	<liferay-ui:search-iterator searchContainer="<%=bienBanBanGiaoSearch %>" />

</liferay-ui:search-container>